<script setup lang="ts">
import { ref } from "vue";
import { PAGINATIONFOOT } from "@/utils/staticData";
import router from "@/router";

defineOptions({ name: "manageTable" });

defineProps({
  tableHeight: { default: 0, type: Number },
  tableData: { type: Array, default: () => [] },
  pagination: { type: Object, default: () => {} }
});
const tableRef = ref<HTMLTableElement | null>(null);

/**
 * 跳转详情
 * @param id
 */
const goToDetail = (id: any) => {
  router.push({
    path: "/inventory/warehouseInventoryAdjustPage",
    query: {
      id: id
    }
  });
};

const goToEdit = (id: any) => {
  router.push({
    path: "/inventory/warehouseInventoryAdjustEditDetail",
    query: { id: id }
  });
};

defineExpose({});
</script>

<template>
  <el-table
    ref="tableRef"
    :data="tableData"
    class="tableBox"
    style="width: 100%"
    :height="
      tableHeight - (pagination.total > pagination.size ? PAGINATIONFOOT : 0)
    "
  >
    <el-table-column type="index" label="序号" min-width="88px" />
    <el-table-column
      prop="adjustCode"
      label="调整单号"
      min-width="184px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="adjustType"
      label="调整类型"
      min-width="184px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="warehouseName"
      label="调整仓库"
      min-width="152px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="createName"
      label="调整人"
      min-width="104px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="createTime"
      label="调整时间"
      min-width="200px"
      show-overflow-tooltip
    />
    <el-table-column
      prop="memo"
      label="备注"
      min-width="200px"
      show-overflow-tooltip
    />
    <el-table-column fixed="right" label="操作" align="left" min-width="128px">
      <template #default="{ row }">
        <el-button type="primary" link @click="goToDetail(row.id)"
          >详情</el-button
        >
        <el-button type="primary" link @click="goToEdit(row.id)"
          >修改</el-button
        >
      </template>
    </el-table-column>
  </el-table>
</template>
